package com.wireless.action;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.wireless.base.BaseAction;
import com.wireless.entity.Menutbl;
import com.wireless.entity.Menutypetbl;
import com.wireless.entity.Orderdetailtbl;
import com.wireless.entity.Ordertbl;
import com.wireless.entity.Purchase;
import com.wireless.entity.Report;
import com.wireless.entity.Tabletbl;
import com.wireless.service.MenuService;
import com.wireless.service.OrderService;
import com.wireless.service.TableService;
import com.wireless.util.CreateOrderId;

@Namespace("/purchase")
@ParentPackage("json-default")
@Controller
public class PurchaseAction extends BaseAction {
	@Autowired
	private OrderService orderService;
	private List<Purchase> purchaseList;
	private Purchase purchase;

	@Action(value = "purchase", results = { @Result(name = "success", location = "/views/purchase/purchase.jsp") })
	public String purchase() {
		purchaseList = orderService.getPurchase();
		return SUCCESS;
	}

	@Action(value = "addPurchase", results = { @Result(name = "success", location = "/views/purchase/purchase.jsp") })
	public String addPurchase() {
		purchase.setCreateTime(new Timestamp(System.currentTimeMillis()));// 创建时间
		orderService.addPurchase(purchase);
		purchaseList = orderService.getPurchase();
		return SUCCESS;
	}

	@Action(value = "getPurCost", results = { @Result(name = "success", type = "json") })
	public String getPurCost() {
		orderService.findPurchaseByMouth();
		return SUCCESS;
	}

	public List<Purchase> getPurchaseList() {
		return purchaseList;
	}

	public void setPurchaseList(List<Purchase> purchaseList) {
		this.purchaseList = purchaseList;
	}

	public Purchase getPurchase() {
		return purchase;
	}

	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}

}
